package com.qianli.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.qianli.pojo.Group;
import com.qianli.pojo.User;
import com.qianli.service.GroupService;
import com.qianli.service.UserService;

public class ActivityAction extends ActionSupport implements SessionAware {
	private UserService userService;
	private GroupService groupService;
	private List<User> userList;
	private List<Group> groupList;
	
	
	private User user;
	private Group group;
	private String Groupid;
	private String GroupName;
	private static final long serialVersionUID = 1L;

	private Map<String, Object> session;
	
	public String execute(){
		 user=(User) session.get("curr_user");
		userList=userService.findBy(user.getId());
		return "success";
	}
	public String invite(){
		return "success";
	}
	public String showGroup(){
	groupList=groupService.showGroup();
		
		return "success";
	}
	public String newGroup(){
		user=(User) session.get("curr_user");
		return "success";
	}
	public String saveGroup(){
		groupService.save(group);
		
		return"success";
	}  
	public String del(){
		groupService.del(Groupid);
		return "success";
	}
	public String toEditGroup(){
		 Group group=groupService.findById(Groupid);
		 session.put("curr_group", group);
		return "success";
	}
	public String editGroup(){
		group=(Group) session.get("curr_group");
		groupService.editGroup(group.getId(),GroupName );
		return"success";
		
	}
	public String userInvite(){
		return"success";
		
	}
	
	public String combineGroup(){
		return"success";
	}
	
	
	
	public String getGroupName() {
		return GroupName;
	}
	public void setGroupName(String groupName) {
		GroupName = groupName;
	}
	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	public void setSession(Map<String, Object>session) {
		this.session=session;
		
	}
	public List<Group> getGroupList() {
		return groupList;
	}
	public void setGroupList(List<Group> groupList) {
		this.groupList = groupList;
	}
	public List<User> getUserList() {
		return userList;
	}
	public void setUserList(List<User> userList) {
		this.userList = userList;
	}
	
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public void setGroup(Group group) {
		this.group = group;
	}
	public void setGroupService(GroupService groupService) {
		this.groupService = groupService;
	}
	public String getGroupid() {
		return Groupid;
	}
	public void setGroupid(String groupid) {
		Groupid = groupid;
	}
	

}
